package com.livesource.client.webservices.subversion;

import com.google.gwt.json.client.JSONObject;
import com.livesource.client.model.entry.ProjectClass;
import com.livesource.client.utilities.ConvertJsonp;

public class ConvertJsonpToFeatureFile {

	public static ProjectClass convert(ProjectClass projectClass,
			JSONObject entry) {

		projectClass.setFileContent(ConvertJsonp.convertToString(entry
				.get("fileContent")));

		projectClass.setFeatureName(ConvertJsonp.convertToString(entry
				.get("featureName")));

		projectClass.setFeatureDescription(ConvertJsonp.convertToString(entry
				.get("featureDescription")));

		if (entry.get("priority") != null) {

			projectClass.setPriority(new Integer(ConvertJsonp
					.convertToString(entry.get("priority"))));
		}

		if (entry.get("estimate") != null
				&& !"null".equals(ConvertJsonp.convertToString(entry
						.get("estimate")))) {

			projectClass.setEstimate(new Integer(ConvertJsonp
					.convertToString(entry.get("estimate"))));
		}

		projectClass
				.setStatus(ConvertJsonp.convertToString(entry.get("status")));

		return projectClass;
	}

}
